package net.bingosoft.common.struts.action;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.bingosoft.common.config.Config;
import net.bingosoft.common.struts.BaseAction;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
 * 2007-10-8 上午11:12:56
 * Author:yangdongyu(yangdy@bingosoft.net)
 * ReadMe:用户注销的action
 * ChangeLog:
 */
public class LogoutUIAction extends BaseAction {
	/**
	 * 用户登录系统的URL
	 */
	private static final String LOGIN_URL = Config.getString("LOGIN_URL");

	public ActionForward doExecute(ActionMapping actionMapping,
			ActionForm actionForm, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		//clear session
		request.getSession().invalidate();
		//清除cookies
		Cookie cookies [] = request.getCookies();
		for(Cookie c : cookies){
			c.setMaxAge(0);
		}
		log.debug("Redirect to url : " + LOGIN_URL);
		return new ActionForward(LOGIN_URL, true);
	}
}